using System.Collections;
using System.Collections.Generic;
using EnvDTE;

namespace Microsoft.WowAddonStudio.Tests.Common.Mocks
{
    public class MockDocuments : List<Document>, Documents
    {
        private readonly string source;

		/// <summary>
		/// Initializes a new instance of the <see cref="MockDocuments"/> class.
		/// </summary>
		/// <param name="dte">The DTE.</param>
		/// <param name="source">The source.</param>
        public MockDocuments(DTE dte, string source)
        {
            DTE = dte;
            this.source = source;
        }

		/// <summary>
		/// Initializes a new instance of the <see cref="MockDocuments"/> class.
		/// </summary>
		/// <param name="dte">The DTE.</param>
		/// <param name="source">The source.</param>
		/// <param name="collection">The collection.</param>
        public MockDocuments(DTE dte, string source, IEnumerable<Document> collection) : base(collection)
        {
            DTE = dte;
            this.source = source;
        }


		/// <summary>
		/// Initializes a new instance of the <see cref="MockDocuments"/> class.
		/// </summary>
		/// <param name="dte">The DTE.</param>
		/// <param name="source">The source.</param>
		/// <param name="capacity">The capacity.</param>
        public MockDocuments(DTE dte, string source, int capacity)
            : base(capacity)
        {
            DTE = dte;
            this.source = source;
        }

        #region Documents Members

		/// <summary>
		/// Returns an enumerator that iterates through a collection.
		/// </summary>
		/// <returns>
		/// An <see cref="T:System.Collections.IEnumerator"/> object that can be used to iterate through the collection.
		/// </returns>
        IEnumerator Documents.GetEnumerator()
        {
            return GetEnumerator();
        }

		/// <summary>
		/// Returns an indexed member of a <see cref="T:EnvDTE.Documents"/> collection.
		/// </summary>
		/// <param name="index">Required. The index of the item to return.</param>
		/// <returns>
		/// A <see cref="T:EnvDTE.Document"/> object.
		/// </returns>
        public Document Item(object index)
        {
            return this[(int) index];
        }

		/// <summary>
		/// Microsoft Internal Use Only.
		/// </summary>
		/// <param name="Kind"></param>
		/// <returns></returns>
        public Document Add(string Kind)
        {
            var doc = new MockDocument(DTE, source, DTE.ActiveDocument.ProjectItem);
            Add(doc);
            return doc;
        }

		/// <summary>
		/// Closes all open documents in the environment and optionally saves them.
		/// </summary>
		/// <param name="Save">Optional. A <see cref="T:EnvDTE.vsSaveChanges"/> constant representing how to react to changes made to documents.</param>
        public void CloseAll(vsSaveChanges Save)
        {
            Clear();
        }

		/// <summary>
		/// Saves all documents currently open in the environment.
		/// </summary>
        public void SaveAll()
        {
            return;
        }

		/// <summary>
		/// Microsoft Internal Use Only.
		/// </summary>
		/// <param name="PathName"></param>
		/// <param name="Kind"></param>
		/// <param name="ReadOnly"></param>
		/// <returns></returns>
        public Document Open(string PathName, string Kind, bool ReadOnly)
        {
            throw new System.NotImplementedException();
        }

		/// <summary>
		/// Gets the top-level extensibility object.
		/// </summary>
		/// <value></value>
		/// <returns>A <see cref="T:EnvDTE.DTE"/> object.</returns>
        public DTE DTE { get; private set; }

		/// <summary>
		/// Gets the immediate parent object of a <see cref="T:EnvDTE.Documents"/> collection.
		/// </summary>
		/// <value></value>
		/// <returns>A <see cref="T:EnvDTE.DTE"/> object.</returns>
        public DTE Parent
        {
            get { return DTE; }
        }

        #endregion

		#region IEnumerable Members
		
		#endregion
	}
}